<template>
  <div class="">
    <Header></Header>
    <div class="main">
      <div class="body">
        <img src="/src/assets/image/vipheader.png" alt="" class="mTop40 nav_img">
        <div class="vipTitle mTop40">
          <div class="vipTitle_left">VIP Члены</div>
          <div class="vipTitle_right">Присоединяйтесь к VIP и получайте скидку</div>
        </div>
        <div class="tigTab">
          <div class="tigTabItem" v-for="index of 4">
            <div class="tigImg">
              <div class="tigTitle">Широкий выбор товаров, быстрая бесплатная доставка</div>
              <div class="tigBtn">Узнать больше</div>
            </div>
            <div class="goodsUl">
              <div class="goodsUlItem" v-for="index of 3">
                <div class="goodImg">
                  <img src="/src/assets/image/cssb.png" alt="">
                </div>
                <div class="goodTitle multi-line-omit">Название товаратоваратовара</div>
                <div class="goodM">398 ₽</div>
              </div>
            </div>
          </div>
        </div>
        <div class="mTop10">
          <Scroll_view type="1" :scrollList="state.scrollList" @clickTab="clickTabFun"></Scroll_view>
        </div>
        <div class="mTop10">
          <Product_list :list="state.goodsObj.list" type="2"></Product_list>
        </div>
      </div>
    </div>
  </div>
</template>

<script lang="ts" name="cart" setup>
import {ref, reactive,onMounted} from "vue";
import Header from '@/components/Header/Header.vue';//引入的头部的主键
import Scroll_view from '@/components/Scroll_view/Scroll_view.vue'
import Product_list from '@/components/Product_list/Product_list.vue'
import {getCategoryList, getIndexList, getVipTopList} from "@/api/api.ts";

const state = reactive({
  scrollList:[],
  goodsObj:{
    list:[],
    total:0,
    page:{
      page:1,
      limit:30,
      topCategoryId:null
    },
  }
})

const getCategoryListFun = () => {
  getCategoryList({level:1}).then((res:any)=>{
    console.log(res)
    state.scrollList = res.returnData
  })
}
const getVipTopListFun = () => {
  getVipTopList({}).then((res:any) =>{

  })
}
const clickTabFun = (topId:any) => {

}
const getIndexListFun = () => {
  getIndexList({...state.goodsObj.page}).then((res:any) => {
    if(res.errCode === 0){
      state.goodsObj.list = [...state.goodsObj.list,...res.returnData.list]
      state.goodsObj.total = res.returnData.total
    }
  })
}
onMounted(() => {
  getCategoryListFun()
  getIndexListFun()
  getVipTopListFun()
})
</script>

<style lang="less" scoped>
.multi-line-omit {
  word-break: break-all; // 允许单词内自动换行，如果一个单词很长的话
  text-overflow: ellipsis; // 溢出用省略号显示
  overflow: hidden; // 超出的文本隐藏
  display: -webkit-box; // 作为弹性伸缩盒子模型显示
  -webkit-line-clamp: 1; // 显示的行
  -webkit-box-orient: vertical; // 设置伸缩盒子的子元素排列方式--从上到下垂直排列
}
.main {
  display: flex;
  flex-direction: column;
  align-items: center;

  .body {
    width: 1400px;

    .nav_img {
      width: 1400px;
      height: 320px;
    }

    .vipTitle{
      display: flex;
      align-content: center;
      .vipTitle_left{
        width: 137px;
        height: 48px;
        background: #0070E9;
        border-radius: 8px 0px 0px 8px;
        font-family: Segoe UI, Segoe UI;
        font-weight: bold;
        font-size: 16px;
        color: #FFFFFF;
        text-align: center;
        line-height: 46px;
      }
      .vipTitle_right{
        width: 380px;
        height: 46px;
        border-radius: 0px 69px 69px 0px;
        border: 1px solid #CCCCCC;

        font-family: Segoe UI, Segoe UI;
        font-weight: 600;
        font-size: 16px;
        color: #333333;
        line-height: 46px;
        text-align: center;
      }
    }
    .tigTab{
      display: flex;
      justify-content: space-between;
      .tigTabItem{
        width: 338px;
        height: 288px;
        //background-color: #2C5AA7;
        border-radius: 16px;
        margin-top: 20px;
        background: #FFFFFF;
        box-shadow: 0px 0px 10px 0px rgba(0,0,0,0.1);
        overflow: hidden;
        .tigImg{
          width: 338px;
          height: 130px;
          border-radius: 16px 16px 0 0px;
          background-image: url('/src/assets/image/beijing1.png');
          background-size: cover;
          background-position: center;
          background-repeat: no-repeat;
          box-sizing: border-box;
          padding: 20px 16px;
          .tigTitle{
            font-family: Segoe UI, Segoe UI;
            font-weight: bold;
            font-size: 20px;
            color: #FFFFFF;
            line-height: 20px;
            text-align: left;
            font-style: normal;
            text-transform: none;
          }
          .tigBtn{
            width: 109px;
            height: 28px;
            background: #FFFFFF;
            border-radius: 20px 20px 20px 20px;
            font-family: PingFang SC, PingFang SC;
            font-weight: bold;
            font-size: 12px;
            color: #8145E0;
            line-height: 28px;
            text-align: center;
            font-style: normal;
            text-transform: none;
            margin-top: 22px;
          }
        }
        .goodsUl{
          display: flex;
          justify-content: space-between;
          box-sizing: border-box;
          padding: 14px;
          .goodsUlItem{
            .goodImg{
              width: 94px;
              height: 94px;
              background-color: #F6F7FB ;
              img{
                width: 100%;
              }
            }
            .goodTitle{
              width: 94px;
              font-family: Segoe UI, Segoe UI;
              font-weight: 600;
              font-size: 12px;
              color: #333333;
              line-height: 12px;
              text-align: left;
              font-style: normal;
              text-transform: none;
            }
            .goodM{
              font-family: Segoe UI, Segoe UI;
              font-weight: bold;
              font-size: 16px;
              color: #F83C57;
              line-height: 16px;
              text-align: left;
              font-style: normal;
              text-transform: none;
              margin-top: 8px;
            }
          }
        }
      }
    }

  }
}
</style>
